this._channel = channel;
this._closedId = this._channel.connect('invalidated', Lang.bind(this, this._channelClosed));
- this._notification = new ChatNotification(this);
- this._notification.connect('activated', Lang.bind(this, this.open));
- this._notification.connect('updated', Lang.bind(this,
- function() {
- if (this._banner && this._banner.expanded)
- this._ackMessages();
- }));
this._notifyTimeoutId = 0;
this._presence = contact.get_presence_type();
// Add ourselves as a source.
Main.messageTray.add(this);
- this.pushNotification(this._notification);
this._getLogMessages();
},
+ _ensureNotification: function() {
+ if (this._notification)
+ return;
+
+ this._notification = new ChatNotification(this);
+ this._notification.connect('activated', Lang.bind(this, this.open));
+ this._notification.connect('updated', Lang.bind(this,
+ function() {
+ if (this._banner && this._banner.expanded)
+ this._ackMessages();
+ }));
+ this._notification.connect('destroy', Lang.bind(this,
+ function() {
+ this._notification = null;
+ }));
+ this.pushNotification(this._notification);
+ },
+
_createPolicy: function() {
return new MessageTray.NotificationApplicationPolicy('empathy');
},
return;
this.setTitle(newAlias);
- this._notification.appendAliasChange(oldAlias, newAlias);
+ if (this._notification)
+ this._notification.appendAliasChange(oldAlias, newAlias);
},
getIcon: function() {
_updateAvatarIcon: function() {
this.iconUpdated();
- this._notification.update(this._notification.title,
- this._notification.bannerBodyText,
- { gicon: this.getIcon() });
+ if (this._notifiction)
+ this._notification.update(this._notification.title,
+ this._notification.bannerBodyText,
+ { gicon: this.getIcon() });
},
open: function() {
let [success, events] = logManager.get_filtered_events_finish(result);
let logMessages = events.map(makeMessageFromTplEvent);
+ this._ensureNotification();
let pendingTpMessages = this._channel.get_pending_messages();
let pendingMessages = [];
if (message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT)
return;
+ this._ensureNotification();
this._pendingMessages.push(message);
this.countUpdated();
// This is called for both messages we send from
// our client and other clients as well.
_messageSent: function(channel, message, flags, token) {
+ this._ensureNotification();
message = makeMessageFromTpMessage(message, NotificationDirection.SENT);
this._notification.appendMessage(message);
},
},
_presenceChanged: function (contact, presence, status, message) {
- this._notification.update(this._notification.title,
- this._notification.bannerBodyText,
- { secondaryGIcon: this.getSecondaryIcon() });
+ if (this._notification)
+ this._notification.update(this._notification.title,
+ this._notification.bannerBodyText,
+ { secondaryGIcon: this.getSecondaryIcon() });
},
_pendingRemoved: function(channel, message) {